home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!cs.utexas.edu!usc!apple!sun-barr!newstop!sun!uunet.UU.NET
- From: sci!jimmc%zax@uunet.UU.NET (Jim McBeath)
- Newsgroups: comp.sources.x
- Subject: v08i067: xfontsel font list enhancement
- Message-ID: <140177@sun.Eng.Sun.COM>
- Date: 4 Aug 90 02:24:18 GMT
- Sender: news@sun.Eng.Sun.COM
- Lines: 604
- Approved: argv@sun.com
-
- Submitted-by: sci!jimmc%zax@uunet.UU.NET (Jim McBeath)
- Posting-number: Volume 8, Issue 67
- Archive-name: xfont.patch/patch
-
- This small patch to xfontsel provides a list of fonts that match the currently
- selected font pattern. You can select any of these fonts and see what the
- sample text looks like with that font, and can select (for pasting into
- other windows) that fully qualified font name in addition to the font pattern.
-
- Jim McBeath globes!jimmc@oliveb.olivetti.com
- Globetrotter Software, Inc. (408)741-0489
- Saratoga, CA
-
- #! /bin/sh
- ## This is a shell archive. Remove anything before this line, then unpack
- ## it by saving it into a file and typing "sh file". To overwrite existing
- ## files, type "sh file -c". You can also feed this as standard input via
- ## unshar, or by typing "sh <file". If this archive is complete, you will
- ## see the following message at the end:
- # "End of shell archive."
- # Contents: XFontSel.ad.diff xfontsel.c.diff xfontsel.man.diff
- # Wrapped by jimmc@ss on Fri Jun 8 11:10:37 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f XFontSel.ad.diff -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"XFontSel.ad.diff\"
- else
- echo shar: Extracting \"XFontSel.ad.diff\" \(1902 characters\)
- sed "s/^X//" >XFontSel.ad.diff <<'END_OF_XFontSel.ad.diff'
- X*** XFontSel.ad Fri Jun 8 11:06:56 1990
- X--- /u2/X11R4/mit/clients/xfontsel/XFontSel.ad Fri Dec 15 07:53:48 1989
- X***************
- X*** 2,8 ****
- X !
- X ! app-defaults for XFontSel
- X !
- X! ! Copyright 1985, 1986, 1987, 1988, 1989, 1990 by the
- X ! Massachusetts Institute of Technology
- X !
- X ! Permission to use, copy, modify, and distribute this
- X--- 2,8 ----
- X !
- X ! app-defaults for XFontSel
- X !
- X! ! Copyright 1985, 1986, 1987, 1988, 1989 by the
- X ! Massachusetts Institute of Technology
- X !
- X ! Permission to use, copy, modify, and distribute this
- X***************
- X*** 20,27 ****
- X ! Author:
- X ! Ralph R. Swick, Digital Equipment Corporation/M.I.T. Project Athena
- X ! one weekend in November, 1989
- X- ! Fontlist added by Jim McBeath, Globetrotter Software, Inc.
- X- ! one day in May, 1990
- X
- X *appDefaultsVersion: 1
- X
- X--- 20,25 ----
- X***************
- X*** 36,51 ****
- X *quitButton.left: chainLeft
- X *quitButton.right: chainLeft
- X
- X! *ownButton.Label: select pattern
- X *ownButton.fromHoriz: quitButton
- X *ownButton.left: chainLeft
- X *ownButton.right: chainLeft
- X
- X- *ownSelButton.Label: select name
- X- *ownSelButton.fromHoriz: ownButton
- X- *ownSelButton.left: chainLeft
- X- *ownSelButton.right: chainLeft
- X-
- X *countLabel.BorderWidth: 0
- X *countLabel.Justify: right
- X *countLabel.Label: 999999 fonts match
- X--- 34,44 ----
- X *quitButton.left: chainLeft
- X *quitButton.right: chainLeft
- X
- X! *ownButton.Label: select
- X *ownButton.fromHoriz: quitButton
- X *ownButton.left: chainLeft
- X *ownButton.right: chainLeft
- X
- X *countLabel.BorderWidth: 0
- X *countLabel.Justify: right
- X *countLabel.Label: 999999 fonts match
- X***************
- X*** 112,121 ****
- X
- X *sampleText*allowResize: true
- X *sampleText*Height: 50
- X-
- X- *matchListViewPort.allowHoriz: TRUE
- X- *matchListViewPort.allowVert: TRUE
- X- *matchListViewPort.height: 200
- X- *matchList.height: 200
- X- *matchList.defaultColumns: 1
- X- *matchList.forceColumns: TRUE
- X--- 105,107 ----
- END_OF_XFontSel.ad.diff
- if test 1902 -ne `wc -c <XFontSel.ad.diff`; then
- echo shar: \"XFontSel.ad.diff\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f xfontsel.c.diff -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"xfontsel.c.diff\"
- else
- echo shar: Extracting \"xfontsel.c.diff\" \(10095 characters\)
- sed "s/^X//" >xfontsel.c.diff <<'END_OF_xfontsel.c.diff'
- X*** xfontsel.c Fri Jun 8 11:05:48 1990
- X--- /u2/X11R4/mit/clients/xfontsel/xfontsel.c Tue Dec 12 11:10:53 1989
- X***************
- X*** 4,10 ****
- X
- X /*
- X
- X! Copyright 1985, 1986, 1987, 1988, 1989, 1990 by the
- X Massachusetts Institute of Technology
- X
- X Permission to use, copy, modify, and distribute this
- X--- 4,10 ----
- X
- X /*
- X
- X! Copyright 1985, 1986, 1987, 1988, 1989 by the
- X Massachusetts Institute of Technology
- X
- X Permission to use, copy, modify, and distribute this
- X***************
- X*** 21,28 ****
- X
- X Author: Ralph R. Swick, DEC/MIT Project Athena
- X one weekend in November, 1989
- X- Fontlist added by Jim McBeath, Globetrotter Software, Inc.
- X- one day in May, 1990
- X */
- X
- X #include <stdio.h>
- X--- 21,26 ----
- X***************
- X*** 34,40 ****
- X #include <X11/Xaw/Cardinals.h>
- X #include <X11/Xaw/Command.h>
- X #include <X11/Xaw/Form.h>
- X- #include <X11/Xaw/List.h>
- X #include <X11/Xaw/MenuButton.h>
- X #include <X11/Xaw/Paned.h>
- X #include <X11/Xaw/SimpleMenu.h>
- X--- 32,37 ----
- X***************
- X*** 68,76 ****
- X void EnableOtherValues();
- X void EnableMenu();
- X void SetCurrentFont();
- X- void SetCurrentMatchList();
- X- void SetSampleTextFont();
- X- void SelectSampleTextFont();
- X Boolean IsXLFDFontName();
- X
- X typedef void (*XtProc)();
- X--- 65,70 ----
- X***************
- X*** 137,143 ****
- X
- X typedef struct FontValues FontValues;
- X struct FontValues {
- X- char *name;
- X int value_index[FIELD_COUNT];
- X };
- X
- X--- 131,136 ----
- X***************
- X*** 174,192 ****
- X int matchingFontCount;
- X static Boolean anyDisabled = False;
- X Widget ownButton;
- X- Widget ownSelButton;
- X Widget fieldBox;
- X Widget countLabel;
- X- Widget matchList;
- X Widget currentFontName;
- X String currentFontNameString;
- X- String selectedFontNameString;
- X- int selectionFlag;
- X int currentFontNameSize;
- X Widget sampleText;
- X static XFontStruct *sampleFont = NULL;
- X Boolean *fontInSet;
- X- String *matchingFontNames;
- X static Choice *choiceList = NULL;
- X int enabledMenuIndex;
- X static Boolean patternFieldSpecified[FIELD_COUNT]; /* = 0 */
- X--- 167,180 ----
- X***************
- X*** 197,204 ****
- X char **argv;
- X {
- X Widget topLevel, pane;
- X- String *l;
- X- Arg args[2];
- X
- X topLevel = XtInitialize( NULL, "XFontSel", options, XtNumber(options),
- X &argc, argv );
- X--- 185,190 ----
- X***************
- X*** 222,232 ****
- X pane = XtCreateManagedWidget("pane",panedWidgetClass,topLevel,NZ);
- X {
- X Widget commandBox, /* fieldBox, currentFontName,*/ viewPort;
- X- Widget matchListViewPort;
- X
- X commandBox = XtCreateManagedWidget("commandBox",formWidgetClass,pane,NZ);
- X {
- X! Widget quitButton /*, ownButton , ownSelButton , countLabel*/;
- X
- X quitButton =
- X XtCreateManagedWidget("quitButton",commandWidgetClass,commandBox,NZ);
- X--- 208,217 ----
- X pane = XtCreateManagedWidget("pane",panedWidgetClass,topLevel,NZ);
- X {
- X Widget commandBox, /* fieldBox, currentFontName,*/ viewPort;
- X
- X commandBox = XtCreateManagedWidget("commandBox",formWidgetClass,pane,NZ);
- X {
- X! Widget quitButton /*, ownButton , countLabel*/;
- X
- X quitButton =
- X XtCreateManagedWidget("quitButton",commandWidgetClass,commandBox,NZ);
- X***************
- X*** 234,248 ****
- X ownButton =
- X XtCreateManagedWidget("ownButton",toggleWidgetClass,commandBox,NZ);
- X
- X- ownSelButton =
- X- XtCreateManagedWidget("ownSelButton",toggleWidgetClass,commandBox,NZ);
- X-
- X countLabel =
- X XtCreateManagedWidget("countLabel",labelWidgetClass,commandBox,NZ);
- X
- X XtAddCallback(quitButton, XtNcallback, Quit, NULL);
- X! XtAddCallback(ownButton,XtNcallback,OwnSelection,(XtPointer)1);
- X! XtAddCallback(ownSelButton,XtNcallback,OwnSelection,(XtPointer)2);
- X }
- X
- X fieldBox = XtCreateManagedWidget("fieldBox", boxWidgetClass, pane, NZ);
- X--- 219,229 ----
- X ownButton =
- X XtCreateManagedWidget("ownButton",toggleWidgetClass,commandBox,NZ);
- X
- X countLabel =
- X XtCreateManagedWidget("countLabel",labelWidgetClass,commandBox,NZ);
- X
- X XtAddCallback(quitButton, XtNcallback, Quit, NULL);
- X! XtAddCallback(ownButton,XtNcallback,OwnSelection,(XtPointer)True);
- X }
- X
- X fieldBox = XtCreateManagedWidget("fieldBox", boxWidgetClass, pane, NZ);
- X***************
- X*** 290,301 ****
- X XtCreateManagedWidget("sampleText",labelWidgetClass,viewPort,NZ);
- X #endif
- X }
- X-
- X- matchListViewPort = XtCreateManagedWidget("matchListViewPort",
- X- viewportWidgetClass,pane,NZ);
- X- matchList = XtCreateManagedWidget("matchList",
- X- listWidgetClass,matchListViewPort,NZ);
- X- XtAddCallback(matchList,XtNcallback,SelectSampleTextFont,(XtPointer)0);
- X }
- X
- X XtRealizeWidget(topLevel);
- X--- 271,276 ----
- X***************
- X*** 415,421 ****
- X
- X fonts = (FontValues*)XtMalloc( numFonts*sizeof(FontValues) );
- X fontInSet = (Boolean*)XtMalloc( numFonts*sizeof(Boolean) );
- X- matchingFontNames = (String *)XtMalloc((numFonts+1)*sizeof(String));
- X for (f = numFonts, b = fontInSet; f; f--, b++) *b = True;
- X for (field = 0; field < FIELD_COUNT; field++) {
- X fieldValues[field] = (FieldValueList*)XtMalloc(sizeof(FieldValueList));
- X--- 390,395 ----
- X***************
- X*** 447,455 ****
- X }
- X parseRec->end = numFonts;
- X ScheduleWork(ParseFontNames,(XtPointer)parseRec,work_priority);
- X- #if 0 /* we're using the names in the FontValues struct now */
- X ScheduleWork((XtProc)XFreeFontNames,(XtPointer)fontNames,work_priority);
- X- #endif
- X ScheduleWork(XtFree, (XtPointer)parseRec, work_priority);
- X SetParsingFontCount(matchingFontCount);
- X if (AppRes.pattern != defaultPattern) {
- X--- 421,427 ----
- X***************
- X*** 496,502 ****
- X continue;
- X }
- X
- X- fontValues->name = *fontNames;
- X for (f = 0, p = *fontNames++; f < FIELD_COUNT; f++) {
- X char *fieldP;
- X
- X--- 468,473 ----
- X***************
- X*** 610,616 ****
- X SetCurrentFontCount();
- X XtSetSensitive(fieldBox, False);
- X XtSetSensitive(ownButton, False);
- X- XtSetSensitive(ownSelButton, False);
- X if (AppRes.app_defaults_version >= MIN_APP_DEFAULTS_VERSION) {
- X #ifdef USE_TEXT_WIDGET
- X XtUnmapWidget(XtParent(sampleText));
- X--- 581,586 ----
- X***************
- X*** 728,734 ****
- X strcpy( label, "no fonts match" );
- X XtSetArg( args[0], XtNlabel, label );
- X XtSetValues( countLabel, args, ONE );
- X- SetCurrentMatchList();
- X }
- X
- X
- X--- 698,703 ----
- X***************
- X*** 802,813 ****
- X }
- X
- X SetCurrentFontCount();
- X- SetSampleTextFont();
- X- }
- X
- X! void
- X! SetSampleTextFont()
- X! {
- X #ifdef USE_TEXT_WIDGET
- X Widget mapWidget = XtParent(sampleText);
- X #else
- X--- 771,778 ----
- X }
- X
- X SetCurrentFontCount();
- X
- X! {
- X #ifdef USE_TEXT_WIDGET
- X Widget mapWidget = XtParent(sampleText);
- X #else
- X***************
- X*** 814,820 ****
- X Widget mapWidget = sampleText;
- X #endif
- X Display *dpy = XtDisplay(mapWidget);
- X! XFontStruct *font = XLoadQueryFont(dpy, selectedFontNameString);
- X if (font == NULL)
- X XtUnmapWidget(mapWidget);
- X else {
- X--- 779,785 ----
- X Widget mapWidget = sampleText;
- X #endif
- X Display *dpy = XtDisplay(mapWidget);
- X! XFontStruct *font = XLoadQueryFont(dpy, currentFontNameString);
- X if (font == NULL)
- X XtUnmapWidget(mapWidget);
- X else {
- X***************
- X*** 824,866 ****
- X XtMapWidget(mapWidget);
- X if (sampleFont) XFreeFont( dpy, sampleFont );
- X sampleFont = font;
- X! OwnSelection( sampleText, (XtPointer)0, (XtPointer)True );
- X }
- X FlushXqueue(dpy);
- X }
- X
- X- void
- X- SelectSampleTextFont(w,closure,callData)
- X- Widget w;
- X- XtPointer closure, callData;
- X- {
- X- XawListReturnStruct *xlr=(XawListReturnStruct *)callData;
- X
- X- selectedFontNameString = xlr->string;
- X- SetSampleTextFont();
- X- }
- X-
- X- void
- X- SetCurrentMatchList()
- X- {
- X- int f,n;
- X- Boolean *b;
- X-
- X- n=0;
- X- if (matchingFontCount) {
- X- for (f=0, b=fontInSet; f<numFonts; f++, b++) {
- X- if (*b) {
- X- matchingFontNames[n++] = fonts[f].name;
- X- }
- X- }
- X- }
- X- matchingFontNames[n] = (String)0;
- X- XawListChange(matchList,matchingFontNames,n,0,1);
- X- if (n>0)
- X- XawListHighlight(matchList,0);
- X- selectedFontNameString = matchingFontNames[0];
- X- }
- X-
- X MarkInvalidFonts( set, val )
- X Boolean *set;
- X FieldValue *val;
- X--- 789,801 ----
- X XtMapWidget(mapWidget);
- X if (sampleFont) XFreeFont( dpy, sampleFont );
- X sampleFont = font;
- X! OwnSelection( sampleText, (XtPointer)False, (XtPointer)True );
- X }
- X FlushXqueue(dpy);
- X+ }
- X }
- X
- X
- X MarkInvalidFonts( set, val )
- X Boolean *set;
- X FieldValue *val;
- X***************
- X*** 1072,1079 ****
- X
- X if (*target == XA_STRING) {
- X *type = XA_STRING;
- X! *value = (selectionFlag==2)?
- X! selectedFontNameString:currentFontNameString;
- X *length = strlen(*value);
- X *format = 8;
- X return True;
- X--- 1007,1013 ----
- X
- X if (*target == XA_STRING) {
- X *type = XA_STRING;
- X! *value = currentFontNameString;
- X *length = strlen(*value);
- X *format = 8;
- X return True;
- X***************
- X*** 1114,1122 ****
- X Widget w;
- X XtPointer closure, callData;
- X {
- X- Arg args[1];
- X Time time = XtLastTimestampProcessed(XtDisplay(w));
- X! int primary = (int)closure;
- X Boolean own = (Boolean)callData;
- X
- X if (_XA_PRIMARY_FONT == NULL)
- X--- 1048,1055 ----
- X Widget w;
- X XtPointer closure, callData;
- X {
- X Time time = XtLastTimestampProcessed(XtDisplay(w));
- X! Boolean primary = (Boolean)closure;
- X Boolean own = (Boolean)callData;
- X
- X if (_XA_PRIMARY_FONT == NULL)
- X***************
- X*** 1125,1135 ****
- X if (own) {
- X XtOwnSelection( w, XA_PRIMARY_FONT, time,
- X ConvertSelection, LoseSelection, DoneSelection );
- X! if (primary) {
- X! selectionFlag = primary;
- X XtOwnSelection( w, XA_PRIMARY, time,
- X ConvertSelection, LoseSelection, DoneSelection );
- X- }
- X if (!XtIsSensitive(currentFontName)) {
- X XtSetSensitive(currentFontName, True);
- X }
- X--- 1058,1066 ----
- X if (own) {
- X XtOwnSelection( w, XA_PRIMARY_FONT, time,
- X ConvertSelection, LoseSelection, DoneSelection );
- X! if (primary)
- X XtOwnSelection( w, XA_PRIMARY, time,
- X ConvertSelection, LoseSelection, DoneSelection );
- X if (!XtIsSensitive(currentFontName)) {
- X XtSetSensitive(currentFontName, True);
- X }
- END_OF_xfontsel.c.diff
- if test 10095 -ne `wc -c <xfontsel.c.diff`; then
- echo shar: \"xfontsel.c.diff\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f xfontsel.man.diff -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"xfontsel.man.diff\"
- else
- echo shar: Extracting \"xfontsel.man.diff\" \(4250 characters\)
- sed "s/^X//" >xfontsel.man.diff <<'END_OF_xfontsel.man.diff'
- X*** xfontsel.man Fri Jun 8 11:06:01 1990
- X--- /u2/X11R4/mit/clients/xfontsel/xfontsel.man Thu Dec 21 08:09:48 1989
- X***************
- X*** 42,50 ****
- X font specifier will be written to standard output when the \fIquit\fP
- X button is activated. Regardless of whether or not \fB-print\fP was
- X specified, the font specifier may be made the PRIMARY (text)
- X! selection by activating the \fIselect pattern\fP button,
- X! or the selected font may be made the PRIMARY selection by
- X! activating the \fIselect name\fP button.
- X .PP
- X The \fB-sample\fP option specifies the sample text to be used to
- X display the selected font, overriding the default.
- X--- 42,48 ----
- X font specifier will be written to standard output when the \fIquit\fP
- X button is activated. Regardless of whether or not \fB-print\fP was
- X specified, the font specifier may be made the PRIMARY (text)
- X! selection by activating the \fIselect\fP button.
- X .PP
- X The \fB-sample\fP option specifies the sample text to be used to
- X display the selected font, overriding the default.
- X***************
- X*** 63,90 ****
- X assert ownership of the PRIMARY_FONT selection. Other applications
- X (see, e.g., \fIxterm\fP) may then retrieve the selected font specification.
- X .PP
- X! When a new font pattern is selected, \fIxfontsel\fP will update the list
- X! of full font names in the font list below the sample text.
- X! By default, the first font in this list is selected as the current font.
- X! By pressing the left pointer button on any font name in the list,
- X! you can select that font.
- X! In addition to updating the sample text using the new font,
- X! \fIxfontsel\fP will set the PRIMARY_FONT selection to the selected font.
- X! .PP
- X! Clicking the left pointer button in the \fIselect pattern\fP widget will
- X! cause the currently selected font pattern to become the PRIMARY text
- X selection as well as the PRIMARY_FONT selection.
- X This then allows you to paste the string into other
- X! applications.
- X! Similarly, clicking the left pointer button in the \fIselect name\fP
- X! widget will cause the currently selected full font name to become the
- X! PRIMARY text selection as well as the PRIMARY_FONT selection.
- X! The \fBselect pattern\fP or \fPselect name\fP button remains
- X highlighted to remind you of this fact, and de-highlights when
- X some other application takes the PRIMARY selection away. The
- X! \fIselect\fP widgets are toggles; pressing one when it is highlighted
- X will cause \fIxfontsel\fP to release the selection ownership and
- X! de-highlight the widget. Activating one of the \fIselect\fP widgets twice
- X is the only way to cause \fIxfontsel\fP to release the
- X PRIMARY_FONT selection.
- X .PP
- X--- 61,76 ----
- X assert ownership of the PRIMARY_FONT selection. Other applications
- X (see, e.g., \fIxterm\fP) may then retrieve the selected font specification.
- X .PP
- X! Clicking the left pointer button in the \fIselect\fP widget will
- X! cause the currently selected font name to become the PRIMARY text
- X selection as well as the PRIMARY_FONT selection.
- X This then allows you to paste the string into other
- X! applications. The \fBselect\fP button remains
- X highlighted to remind you of this fact, and de-highlights when
- X some other application takes the PRIMARY selection away. The
- X! \fIselect\fP widget is a toggle; pressing it when it is highlighted
- X will cause \fIxfontsel\fP to release the selection ownership and
- X! de-highlight the widget. Activating the \fIselect\fP widget twice
- X is the only way to cause \fIxfontsel\fP to release the
- X PRIMARY_FONT selection.
- X .PP
- X***************
- X*** 160,170 ****
- X to stderr but otherwise nothing bad (or good) happens.
- X .PP
- X .SH COPYRIGHT
- X! Copyright 1989, 1990 by the Massachusetts Institute of Technology.
- X .br
- X See \fIX(1)\fP for a full statement of rights and permissions.
- X .SH AUTHOR
- X .PP
- X! Ralph R. Swick, Digital Equipment Corporation/MIT Project Athena.
- X! .br
- X! Fontlist added by Jim McBeath, Globetrotter Software Inc.
- X--- 146,156 ----
- X to stderr but otherwise nothing bad (or good) happens.
- X .PP
- X .SH COPYRIGHT
- X! Copyright 1989 by the Massachusetts Institute of Technology
- X .br
- X See \fIX(1)\fP for a full statement of rights and permissions.
- X .SH AUTHOR
- X .PP
- X! Ralph R. Swick, Digital Equipment Corporation/MIT Project Athena
- X!
- X!
- END_OF_xfontsel.man.diff
- if test 4250 -ne `wc -c <xfontsel.man.diff`; then
- echo shar: \"xfontsel.man.diff\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo shar: End of shell archive.
- exit 0
-
- dan
- ----------------------------------------------------
- O'Reilly && Associates argv@sun.com / argv@ora.com
- Opinions expressed reflect those of the author only.
-